<?php

namespace App\Http\Requests\Logic\Position;

use App\Exceptions\GeneralException;
use Illuminate\Foundation\Http\FormRequest;

class DestroyResource extends FormRequest
{
	/**
	 * Date: 27/04/2018
	 * @author George
	 * @return bool
	 * @throws GeneralException
	 */
    public function authorize()
    {
    	if ($this->position->users()->count() > 0) {
			throw new GeneralException('岗位存在成员，清先将人员转移到其他岗位', 422);
		} else {
    		return true;
		}
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //
        ];
    }
}
